/**
 * Created by Administrator on 2019/5/20/020.
 */
import CZML_GENERALTOOLS_CLASS from "./../main/CZML_GENERALTOOLS_CLASS.js"
import CZML_CummunicationArc from "./CZML_CummunicationArc.js"
import CZML_PIXEL_CLASS from "../main/CZML_PIXEL_CLASS.js"
/**
 * ���ӿ���������������ɻ�����������ǡ��ռ�վ��̽�����ȿ�������������п���켣����
 * @param id <String> ����ƽ̨������UUID
 * @param name <String> �������������
 * @param OrbitStartTime <String> �����ʼʱ�䣬�����ʽΪUTCG
 * @param OrbitEndTime �������ʱ�䣬�����ʽΪUTCG
 * @param position <Array> ���������λ�ã�[�����1,X1,Y1,Z1,�����2,X2,Y2,Z2]([0,30,30,30,5,30,30,30])��XYZΪ���ĵع�����ϵ��
 * @param orientation <Array> �����������̬��[�����1,q1,q2,q3,q0]([0,0,0,0,1])��q0Ϊ����
 * @param ModelVisible <Boolean>��ά��ǩ�Ƿ�ɼ�
 * @param Model3DPath <String> ��άģ��·��
 * @param ModelSize <Number> ��άģ�ʹ�С
 * @param MarkerVisible <Boolean>��ά��ǩ�Ƿ�ɼ�
 * @param MarkerPath <String> ��ά��ǩͼƬ·��
 * @param MaekerPixelSize <Number> ��ά��ǩͼƬ��С
 * @param MarkerColor <Array> ��ά��ǩ��ɫ��[R,G,B,255]��[255,0,0,255]��
 * @param MarkerXOriginPos <String> ��ά��ǩˮƽ���룬���ֿ�ѡ��"CENTER"��"LEFT"��"RIGHT"��
 * @param MarkerYOriginPos <String> ��ά��ǩ��ֱ���룬���ֿ�ѡ��"CENTER"��"LEFT"��"RIGHT"��
 * @param OrbitVisible <Boolean> �켣�Ƿ�ɼ�
 * @param OrbitLineStyle <Number> �켣���0����ֱ�ߣ�1��������
 * @param OrbitLineWidth <Number> �켣����
 * @param OrbitColor <Array> �켣��ɫ��[R,G,B,255]��[255,0,0,255]��
 * @param Distance <Number> ����άͼ���л��ľ��룬(5.5e6)
 * @param ReferenceFrame <String> �켣��̬�Ĳο�ϵ�趨���ַ��������ֿ�ѡ��"FIXED" ��"INERTIAL"��Ĭ��Ϊ"FIXED"
 * @param hiddenTimeSecs ����ڷ���ʱ�䣬�趨�������ص�������0.5
 * @param zhengliuzhaoAStartTime <String> ������A����ʱ�� ISO8601 "2017-11-29T22:50:00Z"
 * @param zhengliuzhaoBStartTime <String> ������B����ʱ�� ISO8601 "2017-11-29T22:50:00Z"
 * @param xin01jiStartTime <String> xin01ji����ʱ�� ISO8601 "2017-11-29T22:50:00Z"
 * @param xin02jiStartTime <String> xin02ji����ʱ�� ISO8601 "2017-11-29T22:50:00Z"
 * @param zhutuiAStartTime <String> ����A����ʱ�� ISO8601 "2017-11-29T22:50:00Z"
 * @param zhutuiBStartTime <String> ����B����ʱ�� ISO8601 "2017-11-29T22:50:00Z"
 * @param zhutuiCStartTime <String> ����C����ʱ�� ISO8601 "2017-11-29T22:50:00Z"
 * @param zhutuiDStartTime <String> ����D����ʱ�� ISO8601 "2017-11-29T22:50:00Z"
 * @param shangmianjiStartTime <String> ���������ʱ�� ISO8601 "2017-11-29T22:50:00Z"
 * @param unBiasedPositionArray: <Array>�ڵ����λ�þ���Ĭ��Ϊ������
 * @return <Undefined>
 */
// model.CZML_MODEL_AddSpacecraftAnimatedModel("LaunchVehicle/CZ", "�������", "29 Nov 2017 22:44:11.000", "29 Nov 2017 23:44:11.000", TESTDATA.CZ_Position, TESTDATA.CZ_Attitude, true, "../SampleData/cz5hjdh.gltf", 1700, true, "../SampleData/jasmine_favicon.png", 1, [0,255,255,255], "CENTER", "CENTER", true, 0, 2, [255,0,255,255],9e6,"FIXED",0,["zhengliuzhaoA"], ["2017-11-29T22:44:11Z"], "2017-11-29T22:50:00Z","2017-11-29T22:50:20Z","2017-11-29T22:50:40Z","2017-11-29T22:51:20Z","2017-11-29T22:51:40Z","2017-11-29T23:44:11Z","2017-11-29T23:44:11Z","2017-11-29T23:44:11Z","2017-11-29T23:44:11Z",[0, 0, 0, 0,100, 300, -400, -400,1000, 300, -4000, -400,2000, 300, -4000, -400]);
class CZML_SpacecraftAnimatedModel {
    constructor(viewer, id, name, OrbitStartTime, OrbitEndTime, position, orientation, ModelVisible, Model3DPath, ModelSize,
                MarkerVisible, MarkerPath, MaekerPixelSize, MarkerColor, MarkerXOriginPos, MarkerYOriginPos,
                OrbitVisible, OrbitLineStyle, OrbitLineWidth, OrbitColor, Distance, ReferenceFrame, hiddenTimeSecs, zhengliuzhaoAStartTime, zhengliuzhaoBStartTime,
                xin01jiStartTime, xin02jiStartTime, zhutuiAStartTime, zhutuiBStartTime, zhutuiCStartTime, zhutuiDStartTime, shangmianjiStartTime, unBiasedPositionArray, BiasedPositionArray) {
        this._viewer = viewer
        this.id = id
        this.name = name
        this.OrbitStartTime = OrbitStartTime
        this.OrbitEndTime = OrbitEndTime
        this.position = position
        this.orientation = orientation
        this.ModelVisible = ModelVisible
        this.Model3DPath = Model3DPath
        this.ModelSize = ModelSize
        this.MarkerVisible = MarkerVisible
        this.MarkerPath = MarkerPath
        this.MaekerPixelSize = MaekerPixelSize
        this.MarkerColor = MarkerColor
        this.MarkerXOriginPos = MarkerXOriginPos
        this.MarkerYOriginPos = MarkerYOriginPos
        this.OrbitVisible = OrbitVisible
        this.OrbitLineStyle = OrbitLineStyle
        this.OrbitLineWidth = OrbitLineWidth
        this.OrbitColor = OrbitColor
        this.Distance = Distance
        this.ReferenceFrame = ReferenceFrame
        this.hiddenTimeSecs = hiddenTimeSecs
        this.zhengliuzhaoAStartTime = zhengliuzhaoAStartTime
        this.zhengliuzhaoBStartTime = zhengliuzhaoBStartTime
        this.xin01jiStartTime = xin01jiStartTime
        this.xin02jiStartTime = xin02jiStartTime
        this.zhutuiAStartTime = zhutuiAStartTime
        this.zhutuiBStartTime = zhutuiBStartTime
        this.zhutuiCStartTime = zhutuiCStartTime
        this.zhutuiDStartTime = zhutuiDStartTime
        this.shangmianjiStartTime = shangmianjiStartTime
        this.unBiasedPositionArray = unBiasedPositionArray
        this.BiasedPositionArray = BiasedPositionArray
        this.CZML_AddSpacecraftAnimatedModel()
    }

    CZML_AddSpacecraftAnimatedModel() {

            const sOrbitStartTime = CZML_GENERALTOOLS_CLASS.Utcg2ISO8601TimeTransformation(this.OrbitStartTime)
            const sOrbitEndTime = CZML_GENERALTOOLS_CLASS.Utcg2ISO8601TimeTransformation(this.OrbitEndTime)
            const AvailabilityTime = sOrbitStartTime + "/" + sOrbitEndTime
            const JulianDateOfOrbitStartTime = Cesium.JulianDate.fromIso8601(sOrbitStartTime)
            const JulianDateOfOrbitEndTime = Cesium.JulianDate.fromIso8601(sOrbitEndTime)
            const OverallSeconds = (JulianDateOfOrbitEndTime.dayNumber - JulianDateOfOrbitStartTime.dayNumber) * 86400 + (JulianDateOfOrbitEndTime.secondsOfDay - JulianDateOfOrbitStartTime.secondsOfDay)
            const OrbitObject = {
                id: this.id,
                availability: AvailabilityTime,
                name: this.name,
                billboard: {
                    eyeOffset: {
                        cartesian: [
                            0, 0, 0
                        ]
                    },
                    horizontalOrigin: this.MarkerXOriginPos,
                    distanceDisplayCondition: {
                        distanceDisplayCondition: [this.Distance]
                    },
                    image: this.MarkerPath,
                    pixelOffset: {
                        cartesian2: [
                            0, 0
                        ]
                    },
                    scale: this.MaekerPixelSize,
                    show: this.MarkerVisible,
                    verticalOrigin: this.MarkerYOriginPos
                },
                label: {
                    fillColor: {
                        rgba: this.MarkerColor
                    },
                    font: "11pt Lucida Console",
                    horizontalOrigin: "LEFT",
                    pixelOffset: {
                        cartesian2: [
                            10, 0
                        ]
                    },
                    show: this.MarkerVisible,
                    style: "FILL_AND_OUTLINE",
                    text: this.name,
                    verticalOrigin: "CENTER"
                },
                path: {
                    show: [
                        {
                            interval: CZML_GENERALTOOLS_CLASS.HEU_ScenarioTime,
                            boolean: this.OrbitVisible
                        }
                    ],
                    width: this.OrbitLineWidth,
                    material: CZML_GENERALTOOLS_CLASS.GetMaterialObject(this.OrbitLineStyle, this.OrbitColor),
                    resolution: 120
                },
                model: {
                    gltf: this.Model3DPath,
                    scale: this.ModelSize,
                    distanceDisplayCondition: {
                        distanceDisplayCondition: [0, this.Distance]
                    },
                    show: this.ModelVisible,
                    runAnimations: false,
                    nodeTransformations: CZML_GENERALTOOLS_CLASS.HEU_ControlAnimationNode(this.hiddenTimeSecs,
                                                                  this.zhengliuzhaoAStartTime, this.zhengliuzhaoBStartTime, this.xin01jiStartTime, this.xin02jiStartTime,
                                                                  this.zhutuiAStartTime, this.zhutuiBStartTime, this.zhutuiCStartTime, this.zhutuiDStartTime, this.shangmianjiStartTime,
                                                                  OverallSeconds, this.unBiasedPositionArray, this.BiasedPositionArray)
                },
                position: {
                    interpolationAlgorithm: "LAGRANGE",
                    interpolationDegree: 5,
                    referenceFrame: this.ReferenceFrame,
                    epoch: sOrbitStartTime,
                    cartesian: this.position
                },
                orientation: {
                    interpolationAlgorithm: "LAGRANGE",
                    interpolationDegree: 1,
                    epoch: sOrbitStartTime,
                    unitQuaternion: this.orientation
                }
            }
            CZML_GENERALTOOLS_CLASS.InsertModelObjectInformation(this.id, OrbitObject, true)
            // ���ӹ����ʾ����
            const idOther = [null]
            const vOrbitStartTime = [this.OrbitStartTime]
            const vOrbitEndTime = [this.OrbitEndTime]
            const pixel = new CZML_PIXEL_CLASS(this._viewer)
            pixel.CZML_PIXEL_AddCummunicationArc(this.id, idOther, this.OrbitVisible, vOrbitStartTime, vOrbitEndTime)
        }

}
export default CZML_SpacecraftAnimatedModel
